package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.StreamCorruptedException;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;

import dao.StuinfoDao;
import entity.StuInfo;

public class BiaoGe extends JFrame{
 
	
	
	
	
	public BiaoGe() {
		setTitle("学生信息");
		setSize(800, 600);
		setVisible(true);
		setLocation(300, 100);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		
		DefaultTableModel dtm=new DefaultTableModel(new Object[][]{},new String[]{"id","name","sex"});
		JTable table=new JTable(dtm);
		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		JScrollPane jsp =new JScrollPane(table);
	    jsp.setPreferredSize(new Dimension(800, 600));
		add(jsp);
		StuinfoDao stuinfoDao=new StuinfoDao();
		StuInfo stuInfo=new StuInfo();
		List<StuInfo> list= stuinfoDao.getAll();
		for (StuInfo s : list) {
			dtm.addRow(s.toArray());
		}
		
		
		
		
	}
    public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				new BiaoGe();
				
			}
		});
	}
	
	
}
